import * as TYPES from "../action-types";
import { Map } from "immutable";
let initState = Map({
  songCat: {},
  songCatList: [],
  songCatParams: {
    cat: "全部",
    offset: 1,
    limit: 20,
  },
  total: 0,
});
function rank(state = initState, action) {
  const { type, payload } = action;
  switch (type) {
    case TYPES.SONG_CAT:
      return state.set("songCat", payload);
    case TYPES.SONG_LIST:
      return state
        .set("songCatList", payload.playlists)
        .set("total", payload.total);
    case TYPES.CHANGE_CURRENT_CATEGORY:
      return state.set("songCatParams", payload);
    default:
      return state;
  }
}

export default rank;
